package com.soft.jdbc.student.utils;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/6/6
 */
public class DBUtil {
    private static final ComboPooledDataSource dataSource = new ComboPooledDataSource("mysql");

    public static Connection getConn() throws SQLException {
        return dataSource.getConnection();
    }

    public static void close(Connection conn) {
        try {
            if (conn != null) conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}